Printing Groups on New Pages and Resetting Page Count

Introduction

This example illustrates a situation where it is desired to print each group on a new page and to reset the page number to 1 for each group.  The COUNTER and RESETEXPR functions will be utilized to accomplish this.

Example 1 showed how to reset the SUM and COUNT functions after printing (by selecting the “Reset after print” check box). For this example the PAGENUMBER function seemingly could be used to print the page number, however this function cannot be reset. Instead the COUNTER function is used to count pages since this function can be reset using the RESETEXPR function when required.

The Employees, Orders, Order_Details, and Products tables within the sample database are used within this example.  The report will list all sales orders per employee as shown below:

This image shows the image to be designed.  It contains an employee name followed by numerous orders placed by that employee.

 

Note that the page numbers increment for each employee, but reset to 1 for the next employee.

The following describes the format of the report.

This image shows the final report design.  The report is titled Employee sales and contains sale date, quantity, and productn name for each sales person.

Force Group Header on new page

To force the Group Header to print on a new page, double-click on the Group Header to launch the Group Header options dialog. On the dialog, check the option to “Force new page (before)”.
Group header options dialog. The Force new page (before) option is selected.

The report design above shows a COUNTER function in the Page Footer band.  Every time the band prints (once per page), the counter increments. 

Reset the COUNTER expression

The name of the COUNTER expression must be obtained such that it can be reset within the RESETEXPR function.  To obtain the name, right-click on the [‘Page ‘ +  COUNTER] expression then click “Options’ to obtain the Expression Name, which in this case is Expression1.

The expression options dialog with the name of the Expression filled in.  The expression name is Expression one.

To force the page counter to reset for each group, the RESETEXPR function must contain the expression to reset (the COUNTER expression) when this band (Group Header) is printed.  Therefore ’Expression1’ is entered as the parameter as shown in the figure below. The expression name must be enclosed within single quotes.

The Edit Expression Field dialog with ResetEXPR entered into the Expression field. Expression 1 enclosed in single quotes and within parentheses follows the reset expr function.